import React, { Component } from 'react'
import PropTypes from 'prop-types'
import Item from '../Item'
import './index.css'

export default class index extends Component {

    // 对接收的props进行类型、必要性的限制
    static propTypes = {
        todos: PropTypes.array.isRequired,
        switchDone: PropTypes.func.isRequired,
        deleteTodo: PropTypes.func.isRequired
    }

    render() {
        const { todos, switchDone, deleteTodo } = this.props
        return (
            <div className="list">
                {
                    todos.map(v => {
                        return <Item key={v.id} id={v.id} todo={v} switchDone={switchDone} deleteTodo={deleteTodo} />
                    })
                }
            </div>
        )
    }
}
